package com.edu.exam.enums.assessment;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 变更类型枚举
 *
 * 考核相关的变更类型管理，用于记录各种变更操作
 *
 * @author System
 * @version 1.0.0
 */
public enum ChangeType implements BaseEnum {

    /**
     * 创建
     */
    CREATE("CREATE", "创建"),

    /**
     * 更新
     */
    UPDATE("UPDATE", "更新"),

    /**
     * 删除
     */
    DELETE("DELETE", "删除"),

    /**
     * 审核
     */
    APPROVE("APPROVE", "审核"),

    /**
     * 取消
     */
    CANCEL("CANCEL", "取消"),

    /**
     * 发布
     */
    PUBLISH("PUBLISH", "发布"),

    /**
     * 修改
     */
    MODIFY("MODIFY", "修改"),

    /**
     * 其他
     */
    OTHER("OTHER", "其他");

    private final String code;
    private final String description;

    ChangeType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public String getJsonValue() {
        return code;
    }

    /**
     * 根据代码获取枚举值
     *
     * @param code 代码
     * @return 对应的枚举值
     * @throws IllegalArgumentException 如果代码无效
     */
    public static ChangeType fromCode(String code) {
        for (ChangeType type : ChangeType.values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown change type code: " + code);
    }

  
    @Override
    public String toString() {
        return description;
    }
}